import { EntitySchema } from '@mikro-orm/core';

export class LePromoterOrder {
  id!: string;
  UID!: string;
  orderSn!: string;
  orderGoodsId!: string;
  goodsNumber!: number;
  commissionNumber!: number;
  totalAmount!: string;
  profitsAmount!: string;
  status: boolean = false;
  countRules?: boolean = true;
  AppID!: string;
  merchantId!: string;
  createdTime?: number = 0;
  updatedTime?: number = 0;
  deletedTime?: number = 0;
  isDeleted?: number = 0;
}

export const LePromoterOrderSchema = new EntitySchema({
  class: LePromoterOrder,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    UID: { type: 'string', fieldName: 'UID', columnType: 'bigint' },
    orderSn: { type: 'string', length: 50 },
    orderGoodsId: { type: 'string', columnType: 'bigint', index: '订单商品ID' },
    goodsNumber: { type: 'number' },
    commissionNumber: { type: 'number' },
    totalAmount: { type: 'string', columnType: 'numeric(10,2)' },
    profitsAmount: { type: 'string', columnType: 'numeric(10,2)' },
    status: { type: 'boolean', default: false },
    countRules: { type: 'boolean', nullable: true, default: true },
    AppID: { type: 'string', fieldName: 'AppID', length: 50 },
    merchantId: { type: 'string', columnType: 'bigint' },
    createdTime: { type: 'number', nullable: true, default: 0 },
    updatedTime: { type: 'number', nullable: true, default: 0 },
    deletedTime: { type: 'number', nullable: true, default: 0 },
    isDeleted: { type: 'number', columnType: 'tinyint', nullable: true, default: 0 },
  },
});
